﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using DAL;

public partial class admin_SysUserAdd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        

        string account = txtAccount.Text.Trim();
        string password = txtPassWord.Text.Trim();
        string userName = txtUserName.Text.Trim();
        string phone = txtPhone.Text.Trim();
        string email = txtEmail.Text.Trim();
        string remark = txtRemark.Text.Trim();
        SysUser user = new SysUser();
        user.Login_name = account;
        user.Pass_word = ClassMD5.EncryptString(password);
        user.User_name = userName;
        user.Phone = phone;
        user.Email = email;
        user.Remark = remark;

        if (SysUserDAL.Instance.SelectUserCount(" login_name='" + account + "' ") > 0)
        {
            Alert("登陆账号已存在!");
            return;
        }

        if(SysUserDAL.Instance.InsertSysUser(user)>0)
        {
            Alert("新增成功!");
            ExecuteScript("btnAdd();");
        }
        else
        {
            Alert("新增失败!");
        }


    }
}